<?php

namespace App\Service\Wechat;

use App\Helpers\ConfigTrait;
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;

/**
 * 微信事件消息
 */
class WechatEvent implements EventHandlerInterface
{
    use ConfigTrait;

    public function handle($payload = null)
    {
        switch ($payload->Event) {

            case 'subscribe':

                return $this->getConfigValue('replyinfo');

                break;

            case 'unsubscribe':

                \Log::info('取关openid:'.$payload->FromUserName.
                        '取关时间:'.$payload->CreateTime);
                break;

            default:
                //自定义事件
                return $this->getClicKeywordValue($payload->EventKey);
                break;
        }
    }
}
